package behavior2.memento.demo;

import java.util.LinkedList;

public class VersionControlSystem {
	LinkedList<Backup> backups = new LinkedList<Backup>();
	int nextVersion;
	
	public void add(Backup backup){
		backup.verison = ++ this.nextVersion;
		backups.add(backup);
	}
	
	public Backup get(int version){
		for(Backup backup:backups){
			if(backup.verison == version){
				return backup;
			}
		}
		return null;
	}
	
	public Backup getLastVersion(){
		return backups.getLast();
	}
}
